package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/dialog"
	"fyne.io/fyne/v2/layout"
	"fyne.io/fyne/v2/widget"
)

func makeConfigForm(myWindow fyne.Window) *fyne.Container {
	query := NewQuery()
	h_itemEntry := widget.NewEntry()
	d_itemEntry := widget.NewEntry()
	html_prefix, doc_prefix := query.GetConfig()
	h_itemEntry.Text = html_prefix
	d_itemEntry.Text = doc_prefix
	formItem_html_prefix := widget.NewFormItem("html文件前缀", h_itemEntry)
	formItem_doc_prefix := widget.NewFormItem("附件文件前缀", d_itemEntry)
	c_form := widget.NewForm(formItem_html_prefix, formItem_doc_prefix)
	submitBtn := widget.NewButton("保存", func() {
		query.SaveConfig(h_itemEntry.Text, d_itemEntry.Text)
		dialog.ShowInformation("提示", "保存成功,前缀将重新加载...", myWindow)
	})
	submitBtn.Importance = widget.HighImportance
	submitBtn.Refresh()

	infoTxt := widget.NewLabel("配置说明：\n1. html文件前缀：生成html删除命令\n2. 附件文件前缀：用于生成附件资源命令")

	c = container.New(layout.NewVBoxLayout(), infoTxt, c_form, submitBtn)
	return c
}
